package com.b2s.scrumblr.kb.core.util;

import java.util.Collection;
import java.util.List;
import java.util.Random;

/**
 * Created on 2016/9/1.
 */
public class CommonsUtil {

    public static String getId(){
        Random random = new Random();

        return System.currentTimeMillis() + ""+Math.abs(random.nextLong());
    }

    public static boolean isEmpty(byte[] bytes){
        return (bytes == null || bytes.length == 0);
    }

    public static boolean isNotEmpty(Collection collection){
        return (collection != null && !collection.isEmpty());
    }

    public static String getCacheKey(Class clz, Object... params){
        StringBuilder builder = new StringBuilder();
        builder.append(clz.getName());
        for(Object object : params){
            if(object instanceof String){
                builder.append(":").append(object.toString());
                continue;
            }
            builder.append(":").append(ReflectUtil.getKey(object));
        }
        return builder.toString();
    }

    public static void main(String[] args) {
        System.out.println(getId());
    }
}
